package com.allen.controller;

import com.allen.bean.Attention;
import com.allen.bean.Result;
import com.allen.service.AttentionService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.sql.SQLException;
import java.util.List;

/**
 * @Author: allen
 * @Data: 2021.06.28.6:56
 **/
@RestController    //相当于@Controller+@RequestBody
@RequestMapping("/Attention")
@CrossOrigin(origins ="*")
public class AttentionController {

    @Autowired
    private AttentionService attentionService;

    @RequestMapping("hello")
    public String hello(){
        return "hello";
    }

    /**
     * 查询所有关注的人
     * @param attention
     * @return
     * @throws SQLException
     */
    @RequestMapping("selu")
    public Result selUserName(Attention attention)throws SQLException {
        System.out.println("成功进入控制器");
        return attentionService.selu(attention);
    }

    /**
     * 添加关注
     * @param attention
     * @return
     */
    @RequestMapping("add")
    public Result add(Attention attention){
        System.out.println("成功进入控制器");
        return attentionService.add(attention);
    }

    /**
     * 取消关注
     * @param attention
     * @return
     */
    @RequestMapping("del")
    public Result del(Attention attention){
        System.out.println("成功进入控制器");
        return attentionService.del(attention);
    }

    /**
     * 查询是否关注某人
     */
    @RequestMapping("find")
    public Result find(Attention attention){
        System.out.println("进入查询控制器");
        return attentionService.find(attention);
    }
}
